#!/usr/bin/env python3.0

#Find the sum of all the even-valued terms in the Fibonacci sequence
#which do not exceed four million.

def fib(ubound=None):
    a = 0
    b = 1
    while not ubound or b <= ubound:
        (a, b) = (b, a+b)
        yield b

if __name__ == '__main__':
    UBOUND = 4000000
    result = 0    
    for n in fib(UBOUND):
        if n % 2 == 0:
            result += n
    print('Result: {0}'.format(result))
